{php include wl_template('common/header');}
<!-- <link rel="stylesheet" href="{TG_URL_ARES}components/light/light7.min.css"> -->
<link rel="stylesheet" href="{TG_URL_ARES}components/weui/weui.css">
<!-- <script type='text/javascript' src='{TG_URL_ARES}components/light/light7.min.js' charset='utf-8'></script> -->
<script type="text/javascript" src="{MODULE_URL}app/resource/layer/layer.js" ></script>
<script type='text/javascript' src='{TG_URL_ARES}js/laytpl.js' charset='utf-8'></script>
<title>核销中心</title>  
<style>
    body {
        background-color: #fff;
    }
    #footer li:nth-child(2){
        color: #ff5c67;
        opacity: 0.93;
    }
    .voucher-main{overflow:hidden;}
    .voucher-main .list-cash-coupon{padding:10px 0 0 0; list-style:none; margin:10px auto;}
  /*  .voucher-main .list-cash-coupon li{margin:10px 0;}*/
   /* .voucher-main .list-cash-coupon a{display:block;width:281px;height:109px;margin:auto;background:url('resource/images/voucher.png') no-repeat 0 -9px;-webkit-background-size:575px auto;position:relative;}*/
    .voucher-main .list-cash-coupon a>p{position: absolute;max-width:200px;height:20px;color:#FFF;-webkit-box-sizing:border-box;}
    .voucher-main .list-cash-coupon a>p:nth-of-type(1){left:25px;top:20px;font-size:14px;}
    .voucher-main .list-cash-coupon a>p:nth-of-type(1)>span{font-size:30px;}
    .voucher-main .list-cash-coupon a>p:nth-of-type(2){left: 26px;top: 62px;font-size: 14px;}
    .voucher-main .list-cash-coupon a>p:nth-of-type(2):first-letter{font-size:14px;margin-right:3px;}
    .voucher-main .list-cash-coupon a>p:nth-of-type(3){left: 26px;top: 83px;font-size: 12px;}
    .voucher-main .list-cash-coupon a>p:nth-of-type(4){left: 160px;top: 42px;font-size: 11px;}
    .voucher-main .list-cash-coupon a>p:nth-of-type(5){right: 12px;top:18px;font-size:14px;width:25px; line-height:18px;}
    .voucher-main .list-cash-coupon li:nth-of-type(4n+2) a, .list-cash-coupon li .a2{background-position: 0 -133px;}
    .voucher-main .list-cash-coupon li:nth-of-type(4n+3) a, .list-cash-coupon li .a3{background-position: 0 -256px;}
    .voucher-main .list-cash-coupon li:nth-of-type(4n) a, .list-cash-coupon li .a4{background-position: 0 -378px;}
    .voucher-main .list-cash-coupon li[disabled] a{background-position: 0 -502px;}
    .voucher-main .list-cash-coupon li[disabled] a:after{content: "";-webkit-background-size: 110px auto;position: absolute;top: 0;left: 0;width: 100%;height: 100%;z-index: 100;pointer-events: none;}
    .voucher-main .list-cash-coupon li[disabled="expire"] a:after{background-image: url('resource/images/voucher02.png'); background-repeat: no-repeat; background-position:50px 15px;}
    .voucher-main .list-cash-coupon li[disabled] a>p{color:rgba(255,255,255,0.85)!important;}
    .voucher-main .list-cash-coupon li.used a{background-position-x:right!important;}
    .voucher-main .list-cash-coupon li.used:nth-of-type(4n+1) a>p:nth-of-type(5){color:#ee5375;}
    .voucher-main .list-cash-coupon li.used:nth-of-type(4n+2) a>p:nth-of-type(5){color:#ffa619;}
    .voucher-main .list-cash-coupon li.used:nth-of-type(4n+3) a>p:nth-of-type(5){color:#92c427;}
    .voucher-main .list-cash-coupon li.used:nth-of-type(4n) a>p:nth-of-type(5){color:#2f9abd;}
    .voucher-main .read-coupon .list-cash-coupon a>p:nth-of-type(3){left:210px; top:65px; font-size:10px;}
    .bar .button-link{
        color:#ff5c67;
    }
    .buttons-tab {
        position: fixed;
        top:0;
        width: 100%;
        z-index: 10990;
    }
    #footer{
        z-index: 9999;
    }
    .content{
        top:10px;
        bottom: 50px;
    }
    .buttons-tab .button.active{   
        color: #ff5c67;
        border-color: #ff5c67;
        border-bottom: 2px solid;
    }
    .coupon-item {
        position: relative;
        padding: 20px 20px 140px 20px; 
        font-size: 12px;         
        border-top: 1px solid #ccc;
        border-bottom: 1px solid #ccc;
    }
    .coupon-item .coupon-header {
        position: relative;
        margin-bottom: 20px;
        width: 100%;
        /*height: 100px;*/
    }
    .coupon-item .coupon-header img {
        object-fit: cover;
        width: 100%;
        height: 100%;
    }
    .coupon-item .coupon-header .kq-overdue {
        position: absolute;
        top: 50%;
        left: 50%;
        width: 100px;
        height: 40px;
        line-height: 40px;
        vertical-align: middle; 
        transform: translateX(-50%) translateY(-50%);
        color: #fff;
        background-color: rgba(0, 0, 0, 0); 
        border: 1px solid red;
        box-shadow: 0 0 5px red inset;
        font-size: 20px;
        text-align: center;
        transform:rotate(9deg);
        -ms-transform:rotate(9deg); /* Internet Explorer */
        -moz-transform:rotate(9deg); /* Firefox */
        -webkit-transform:rotate(9deg); /* Safari 和 Chrome */
        -o-transform:rotate(9deg); /* Opera */
    }
    .coupon-item .coupon-content {
        display: flex;
        flex-flow: row nowrap;
        justify-content: space-between;
        align-items: center;
    }
    .coupon-item .coupon-coontent .time-bar {

    }
    .time-bar .time-container span {
        display: inline-block;
        width: 200px;  
    }
    .coupon-item .coupon-content .coupon-btn {
        width: 100px;
        height: 30px;
        line-height: 30px;
        box-shadow: 0 0 4px #aaa; 
        background-color: #ff9900;
        vertical-align: middle;
        text-align: center;   
    }
    .coupon-item .coupon-content .done {
        width: 100px;
        height: 30px;
        line-height: 30px;
        color: #aaa;
        box-shadow: 0 0 4px #aaa; 
        background-color: #ccc;
        vertical-align: middle;
        text-align: center;  
    }
    .coupon-item .coupon-content .coupon-btn a{
        width: 100%;
        height: 100%;
        line-height: 100%;
        color: #fff;
        font-weight: 700; 
    }
    .coupon-item .coupon-content .done a {
        width: 100%;
        height: 100%;
        line-height: 100%;
        color: #aaa;
        font-weight: 700; 
    }
    .coupon-item .coupon-desc {
        margin-bottom: 20px; 
        padding-top: 10px;
        /*white-space: nowrap;*/
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 12px;
        color: #bbb;
        border-top: 1px solid #ccc;  
    }
    /*ight7捣乱*/
    .coupon-item .coupon-desc p {
        margin: 0;
    }
    .coupon-item .coupon-desc:last-child{
        margin-bottom: 0;
    }
    
    .content .havekq {
        display: none;
        overflow: scroll;
        /*position: fixed;*/
        top: 40px;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: #fff;
    }
    .content .overdue {
        display: none;
        overflow: scroll;
        margin:30px 0;
        /*position: fixed;*/
        top: 40px;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: #fff;
    }
    .iconal-homefill:before,.iconal-dingdan1:before,.iconal-gerenzhongxin:before{
        height: 28px;
    }
    .weui-check__label {
        display: flex;
        flex-direction: row;
        /*justify-content: space-around;*/
        align-items: center;
    }
    .cell_column {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        align-items: flex-start;
    }
    .cell_column .weui-cell__bd{
        display: inline-block; 
        height: 30px;
    }
    .cell_column .weui-cell__bd {
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
    }
    .cell_column .weui-cell__bd span {
        margin-right: 10px 
    }
    .weui-check__label .weui-cell__hd {     
        flex: 0 0 60px;
    }
    .weui-search-bar__form {
        position: fixed;
        top: 40px;
        z-index: 666;
        width: 100%;
        height: 30px; 
    }
    .bottom_com {
        position: fixed;
        display: flex;
        bottom: 50px;
        z-index: 999;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        height: 60px; 
        background-color: #ff5c67; 
        text-align: center;
        color: #fff;   
    }
    .bottom_com div{
        width: 50%; 
    }
    .bottom_com div:last-child {

    }
    .weui-search-bar__form {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    .weui-search-bar__form .comfirm {
        flex: 0 0 50px;
        width: 50px;
        position: relative;
        z-index: 100; 
    }
    .buttons-tab {
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        background-color: #fff;
        height: 40px;
    }
    .buttons-tab a {
        display:block;
        width: 50%; 
        text-align: center;
        height: 38px;
        line-height: 38px;  
    }
    .both_margin {
        margin: 30px 0;  
    }
</style>
<!-- 未填写个人信息弹窗 -->
<div class="noIdMessage">
    <div>
        <p>请去完善个人信息</p>
        <div class="btn-box">
            <span onclick="location.href='{php echo app_url('order/personnelList');}from=user'" class="yes">好</span>
        </div>
        <!--<i class="iconal-roundclosefill"></i>-->
    </div>
</div>
<div id="footer">{php include wl_template('common/footer');}</div>
<div class="buttons-tab">
    <a href="javascript:;" class="tab-link button active" onclick="showtab1(this);">项目核销</a>
    <a href="javascript:;" class="tab-link button" onclick="showtab2(this)">卡券核销</a>
    <a href="javascript:;" class="tab-link button" onclick="showtab3(this)">发奖</a>
</div>
<div class="page-group">
    <div class="page page-current" id="page-coupon-list">
        <div class="bottom_com">
            <div class="bottom_all checkall">
                全选
            </div>
            <div class="bottom_comfirm"> 
                提交  
            </div>
        </div>
        <!--<header class="bar bar-nav">-->
            <!--<a class="button button-link button-nav pull-left back" href="{php echo app_url('member/home')}">-->
                <!--<span class="icon icon-left"></span>返回-->
            <!--</a>-->
            <!--<h1 class="title">我的优惠券</h1>-->
        <!--</header>-->
        <div class="content native-scroll">

            <div class="tabs">
                <div id="tab1" class="tab active">
                </div>
                <div id="tab2" class="tab">
                </div>
                <div id="tab3" class="tab">
                </div>
            </div>
            <div class="weui-search-bar__form">    
                <div class="weui-search-bar__box">
                    <i class="weui-icon-search"></i>
                    <input type="search" class="weui-search-bar__input" id="searchInput" placeholder="输入身份证或手机号" required="">
                    <a href="javascript:" class="weui-icon-clear" id="searchClear"></a>
                </div>
                <div class="comfirm">
                    确定
                </div> 
            </div>
    			<div class="voucher-main both_margin">
                        <ul class="list-cash-coupon">
                                <li disabled>
                                
                                    <!-- <div class="weui-cell weui-cells_checkbox">
                                            <div class="weui-cell__bd">
                                                <label class="weui-check__label" for="s11">
                                                    <div class="weui-cell__hd">
                                                        多选
                                                    </div>
                                                    <div class="weui-cell__bd">
                                                        <p>项目名称</p>
                                                    </div>
                                                    <div class="weui-cell__bd">
                                                        <p>手机号</p>
                                                    </div>
                                                    <div class="weui-cell__bd">
                                                        <p>身份证</p> 
                                                    </div>
                                                </label>
                                            </div>
                                        </div>  -->
                                    <div class="coupon-item">

                                        <!-- <div class="weui-cell weui-cells_checkbox">
                                            <div class="weui-cell__bd">
                                                <label class="weui-check__label" for="s11">
                                                    <div class="weui-cell__hd">
                                                        <input type="radio" class="weui-check" name="checkbox1" id="s11" checked="checked">
                                                        <i class="weui-icon-checked"></i>
                                                    </div>
                                                    <div class="weui-cell__bd">
                                                        <p>{$item['goodsname']}</p>
                                                    </div>
                                                    <div class="weui-cell__bd">
                                                        <p>{$item['mobile']}</p>
                                                    </div>
                                                    <div class="weui-cell__bd">
                                                        <p>{$item['id_card']}</p>
                                                    </div>
                                                </label>
                                            </div>
                                        </div> --> 

                                    </div>
                            </li>

                    </ul>
                </div>
            <div class="havekq">
                    <ul class="list-cash-coupon" style="padding: 10px 0 0 0;list-style: none;margin: 10px auto;">   
                        <li disabled>
                    <div class="coupon-item both_margin">
                

                    </div>
                    </li>

                </ul>
            </div>

            <div class="overdue">
                <div class="coupon-item">

                </div>
            </div>
        </div>
    </div>
    
</div>
<script>
    var pagenum = 1;
    var pagesize = 10;
    var member = '';
    var uniacid = "{$_W['uniacid']}";
    $(function () {
        'use strict';
        window.ajaxMessList(pagenum,pagesize,member,'item',function (res) {
            var item_html = window.item('item',res);
            $('.voucher-main .coupon-item').html(item_html); 
        });
        console.log(uniacid); 
    });

    // 显示卡券核销
    function showtab2(that) {
        pagenum = 1;
        memder = ''; 
        $('.overdue').hide();
        $('.voucher-main').hide();
        $('.havekq').fadeIn();
        $(that).parent().find('a').removeClass('active'); 
        $(that).addClass('active'); 
        window.ajaxMessList(pagenum,pagesize,member,'coupon',function (res) {
            var coupon_html =  window.item('coupon',res);
            $('.havekq .coupon-item').html(coupon_html); 
        })
    }
    // 显示项目核销
    function showtab1(that) {
        pagenum = 1;
        member = '';
        $('.overdue').hide();
        $('.havekq').hide();
        $('.voucher-main').fadeIn();
        $(that).parent().find('a').removeClass('active'); 
        $(that).addClass('active');
        // window.ajaxMessList(pagenum,pagesize,member,'item',function (res) { 

        // })   
    }
    //显示发奖
    function showtab3(that) {
        pagenum = 1;
        member = '';
        $('.voucher-main').hide();
        $('.havekq').hide();
        $('.overdue').fadeIn();
        $(that).parent().find('a').removeClass('active'); 
        $(that).addClass('active');
        window.ajaxMessList(pagenum,pagesize,member,'prize',function (res) { 
            var prize_html = window.prize(res);
            $('.overdue .coupon-item').html(prize_html); 
        })   
    }
    

    //加载核销列表
        function ajaxMessList(pagenum,pagesize,member,op,callBack){
            $.get(
                hexiaoList + 'op='+op, 
                {
                    page:pagenum,
                    pagesize:pagesize,
                    member: member
                },
                function(data){
                    var res=JSON.parse(data);
                    callBack(res);
                    
                }
            )
        }
        //获取url参数
        function escapeHtml(text) { 
            var a=text.replace(/(\&lt;)/g,"<");
            var b=a.replace(/(\&gt;)/g,">");
            var c=b.replace(/(\&amp;)/g,"\&");
            var d=c.replace(/(\&quot;)/g,"\"");
            return d;
        }  
    //全选
    $('.checkall').click(function () { 
        var active = $('.tab-link').eq(0);
        if(active.hasClass('active')){     
            if($(this).html() === '全选'){
                $('.voucher-main input[type="checkbox"]').prop('checked',true);
                $(this).html('取消全选');
            }else{
                $('.voucher-main input[type="checkbox"]').removeAttr('checked');
                $(this).html('全选');
            }       
        }else if($('.tab-link').eq(1).hasClass('active')){
            if($(this).html() === '全选'){
                $('.havekq input[type="checkbox"]').prop('checked',true);
                $(this).html('取消全选');
            }else{
                $('.havekq input[type="checkbox"]').removeAttr('checked');
                $(this).html('全选');
            }       
        }else{
            if($(this).html() === '全选'){
                $('.overdue input[type="checkbox"]').prop('checked',true);
                $(this).html('取消全选');
            }else{
                $('.overdue input[type="checkbox"]').removeAttr('checked');
                $(this).html('全选');
            }      
        } 
    })
    //搜索
    $('.comfirm').click(function () {    
        pagenum = 1;                            //初始化
        member = $('#searchInput').val();
        if(member == ''){
            $.toast('请输入搜索内容', 'cancel'); 
        }else{
            var active = $('.tab-link').eq(0); 
            if(active.hasClass('active')){
                window.ajaxMessList(pagenum,pagesize,member,'item',function (res) {
                    var item_html = window.item('item',res);
                    $('.voucher-main .coupon-item').html(item_html); 
                }) 
            }else if($('.tab-link').eq(1).hasClass('active')){
                window.ajaxMessList(pagenum,pagesize,member,'coupon',function (res) { 
                    var coupon_html = window.item('coupon',res);
                     $('.havekq .coupon-item').html(coupon_html); 
                })
            }else{
                window.ajaxMessList(pagenum,pagesize,member,'prize',function (res) { 
                    var prize_html = window.prize(res);
                    $('.overdue .coupon-item').html(prize_html); 
                })
            }
        }
    })
    //清空搜索框
    $('#searchClear').click(function () {
        member = '';
        $('#searchInput').val('');
        var active = $('.tab-link').eq(0); 
        if(active.hasClass('active')){
           window.ajaxMessList(pagenum,pagesize,member,'item',function (res) {
                var item_html = window.item('item',res);
                $('.voucher-main .coupon-item').html(item_html); 
           })  
        }else if($('.tab-link').eq(1).hasClass('active')){
            window.ajaxMessList(pagenum,pagesize,member,'coupon',function (res){
                var coupon_html = window.item('coupon',res);
                $('.havekq .coupon-item').html(coupon_html); 
            })
        }else{
            window.ajaxMessList(pagenum,pagesize,member,'prize',function (res) { 
                var prize_html = window.prize(res);
                $('.overdue .coupon-item').html(prize_html); 
            })
        }
        
    })
    // 保持焦点不变的情况下随着输入内容的变化而触发,判断删空的情况下,与清空搜索框相同效果
    $("#searchInput").bind('input propertychange',function(){
        member =  '';
        var active = $('.tab-link').eq(0);
        if($(this).val() == '') {                   //input为空时  
            if(active.hasClass('active')){          //判断当前停留的bar
                window.ajaxMessList(pagenum,pagesize,member,'item',function (res) {
                    var item_html = window.item('item',res);
                    $('.voucher-main .coupon-item').html(item_html); 
                })   
                
            }else if($('.tab-link').eq(1).hasClass('active')){
                window.ajaxMessList(pagenum,pagesize,member,'coupon',function (res){
                    var coupon_html = window.item('coupon',res);
                    $('.havekq .coupon-item').html(coupon_html); 
                })
            }else{
                window.ajaxMessList(pagenum,pagesize,member,'prize',function (res) { 
                    var prize_html = window.prize(res);
                    $('.overdue .coupon-item').html(prize_html); 
                })
            }
        }
    });
    //提交审核 
    $('.bottom_comfirm').click(function () {
        var active = $('.tab-link').eq(0);
         $.confirm('确认提交？',function () {
            if(active.hasClass('active')){
                var member =  $('.voucher-main input[type="checkbox"]');
                // console.log(member);
                var _members = [];
                member.each(function (index,item) {    
                console.log(item);            
                    if(item.checked){       
                        _members.push($(item).attr('id')); 
                    }
                })
                console.log(_members); 
                if(_members.length == 0){
                    $.toast('请选择项目', 'cancel'); 
                    return;
                }
                window.ajaxMessList(pagenum,pagesize,_members,'check_order',function (res) {
                   $.toast('核销成功', 'success'); 
                   setTimeout(function () {
                        window.location.href = window.location.href;    
                   },1500) 
                }) 
            }else if($('.tab-link').eq(1).hasClass('active')){
                var member =  $('.havekq input[type="checkbox"]');
                var _members = [];
                member.each(function (index,item) {              
                    if(item.checked){       
                        _members.push($(item).attr('id')); 
                    }
                }) 
                if(_members.length == 0){ 
                    $.toast('请选择项目', 'cancel');  
                    return;
                }
                window.ajaxMessList(pagenum,pagesize,_members,'check_coupon',function (res) {
                   $.toast('核销成功', 'success');
                   setTimeout(function () {
                        window.location.href = window.location.href;    
                   },1500)         
                })
            }else{
                var member =  $('.overdue input[type="checkbox"]');
                console.log(member);
                var _members = [];
                member.each(function (index,item) {    
                console.log(item);            
                    if(item.checked){       
                        _members.push($(item).attr('idcard')); 
                    }
                })
                console.log(_members); 
                if(_members.length == 0){ 
                    $.toast('请选择项目', 'cancel');  
                    return;
                }
                window.ajaxMessList(pagenum,pagesize,_members,'check_prize',function (res) {
                   // $.toast('成功发奖', 'success');
                   if(res.status == 0){
                    $.toast(res.result,'cancel');
                   }else{
                    $.toast(res.result,'success');
                   }
                   // setTimeout(function () {
                   //      window.location.href = window.location.href;    
                   // },1500)         
                }) 
            }
        })
    })
    //项目核销与卡券核销
    function item(type,res) {
        var data = res.list;
        var length = res.list.length;
        var html = '';    
        console.log(data);
        if(length == 0){
            $.toast('没有该项目信息', 'cancel');
            return;  
        }
        for(var i = 0; i < length; i++) {
            if(type == "item"){
                var num_id = res.list[i].orderno;
                var _name = res.list[i].goodsname;
                var _idcard = res.list[i].id_card;
                var _times = res.list[i].active_times;
            }else if(type == "coupon") {
                var num_id = res.list[i].id;
                var _name = res.list[i].coupon.name; 
                var _idcard = res.list[i].idcard;
                var _times = res.list[i].times;
            };  
            html += '<div class="weui-cell weui-cells_checkbox">'+
                                        '<div class="weui-cell__bd">'+
                                            '<label class="weui-check__label" for='+num_id+'>'+ 
                                                '<div class="weui-cell__hd">'+
                                                    '<input type="checkbox" class="weui-check" name="checkbox1" id='+num_id+'>'+
                                                    '<i class="weui-icon-checked"></i>'+  
                                                '</div>'+
                                                '<div class="cell_column">'+
                                                    '<div class="weui-cell__bd">'+
                                                        '<span>项目名称</span><p>'+_name+'</p>'+
                                                    '</div>'+
                                                    '<div class="weui-cell__bd">'+
                                                        '<span>手机号</span><p>'+res.list[i].mobile+'</p>'+
                                                    '</div>'+
                                                    '<div class="weui-cell__bd">'+
                                                        '<span>身份证</span><p>'+_idcard+'</p>'+
                                                    '</div>'+
                                                    '<div class="weui-cell__bd">'+
                                                        '<span>剩余核销次数</span><p>'+_times+'</p>'+ 
                                                    '</div>'+
                                                '</div>'+
                                            '</label>'+
                                        '</div>'+
                                    '</div>';
        }
        return html;
    }
    //发奖
    function prize (res) {
        var data = res.list;
        var length = res.list.length;
        var html = '';    
        console.log(data);
        if(length == 0){
            $.toast('没有该项目信息', 'cancel');
            return;  
        }
        for(var i = 0; i < length; i++) {  
            html += '<div class="weui-cell weui-cells_checkbox">'+
                                        '<div class="weui-cell__bd">'+
                                            '<label class="weui-check__label" for='+res.list[i].openid+'>'+ 
                                                '<div class="weui-cell__hd">'+
                                                    '<input type="checkbox" class="weui-check" name="checkbox1" idcard='+res.list[i].idcard+' id='+res.list[i].openid+'>'+
                                                    '<i class="weui-icon-checked"></i>'+  
                                                '</div>'+
                                                '<div class="cell_column">'+
                                                    '<div class="weui-cell__bd">'+
                                                        '<span>姓名</span><p>'+res.list[i].realname+'</p>'+
                                                    '</div>'+
                                                    '<div class="weui-cell__bd">'+
                                                        '<span>手机号</span><p>'+res.list[i].mobile+'</p>'+
                                                    '</div>'+
                                                    '<div class="weui-cell__bd">'+
                                                        '<span>身份证</span><p>'+res.list[i].idcard+'</p>'+
                                                    '</div>'+
                                                    '<div class="weui-cell__bd">'+
                                                        '<span>已使用卡券次数:</span><p>'+res.list[i].favorable_times+'</p>'+  
                                                    '</div>'+
                                                    '<div class="weui-cell__bd">'+
                                                        '<span>已使用:</span><p>'+res.list[i].prize_times+'卡券兑换成奖品</p>'+  
                                                    '</div>'+
                                                '</div>'+
                                            '</label>'+
                                        '</div>'+
                                    '</div>';
        }
        return html;
    } 
    //滚动加载
    $(document.body).infinite();//初始化
    var loading = false;  //状态标记
    $(document.body).infinite().on("infinite", function() {
        if(loading) return;
        pagenum++;
        loading = true;
        $.toast('加载中','loading');
        var active = $('.tab-link').eq(0);
        if(active.hasClass('active')){
        setTimeout(function() {
            window.ajaxMessList(pagenum,pagesize,member,'item',function (res) {
                var item_html = window.item('item',res);
                $('.voucher-main .coupon-item').append(item_html);
                window.done(res);         
            })
            loading = false;
            }, 700);   //模拟延迟
        }else if($('.tab-link').eq(1).hasClass('active')){
            setTimeout(function() {
            window.ajaxMessList(pagenum,pagesize,member,'coupon',function (res) {
                var coupon_html = window.item('coupon',res);
                $('.havekq .coupon-item').append(coupon_html);
                window.done(res);         
            })
            loading = false;
            }, 700);   //模拟延迟
        }else{
            setTimeout(function() {
            window.ajaxMessList(pagenum,pagesize,member,'prize',function (res) { 
                var prize_html = window.prize(res);
                $('.overdue .coupon-item').append(prize_html); 
                window.done(res);         
            })
            loading = false;
            }, 700);   //模拟延迟
        }   
    });

    function done (res) {
        if(res.list.length<1){
            // $.toptip('全部完毕', 'success');
            $.toast('数据加载完毕','success');
            $(document.body).destroyInfinite();//停止加载
            return false;
        }
    }

    window.onload=function(){
        $('#footer').on('click','li',function(){
            if($(this).hasClass('gouwuche')){
                ajaxCarList();
                $('#cartDetails').slideDown();
            }else if($(this).hasClass('jishi')) {
                //跳转我的技师 解决local获取不到
                var local=JSON.parse(sessionStorage.getItem('location'))||{latitude:'',longitude:''};
                location.href=personnelUrl+'localLat='+local.latitude+'&localLon='+local.longitude;
            }else{
                location.href = $(this).data('href');
            }
        });
    } 

</script>

